package com.yxq.mdt.app.modules.auction.adapter;

import androidx.annotation.Nullable;

import com.alibaba.android.arouter.utils.TextUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yxq.mdt.app.R;
import com.yxq.mdt.app.modules.auction.bean.AuctionProfitBean;
import com.yxq.mdt.app.modules.auction.bean.AuctionTxBean;

import java.util.List;

public class AuctionProfitAdapter extends BaseQuickAdapter<AuctionTxBean.PmUserIncomeListBean.ListBean, BaseViewHolder> {

    public AuctionProfitAdapter(int layoutResId, @Nullable List<AuctionTxBean.PmUserIncomeListBean.ListBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, AuctionTxBean.PmUserIncomeListBean.ListBean item) {
        helper.setText(R.id.item_auction_money, "￥" + item.getIncomeAmount());
        helper.setText(R.id.item_auction_name, item.getIncomeNote());
        helper.setText(R.id.item_auction_time, item.getCreateTime());
        if (!TextUtils.isEmpty(item.getDescription())) {
            helper.setText(R.id.item_auction_desc, item.getDescription());
        }
        helper.setText(R.id.item_auction_type, getDesc(item.getIsEntry()));
        if (item.getIsEntry() == 0) {
            helper.setTextColor(R.id.item_auction_type, mContext.getResources().getColor(R.color.color_font_gray));
        } else if (item.getIsEntry() == 1) {
            helper.setTextColor(R.id.item_auction_type, mContext.getResources().getColor(R.color.color_font_green));
        }
        if (item.getIsEntry() == 2) {
            helper.setTextColor(R.id.item_auction_type, mContext.getResources().getColor(R.color.color_font_red));
        }
    }

    private String getDesc(int entry) {
        switch (entry) {
            case 0:
                return "待订单确认收货后到账";
            case 1:
                return "已到账";
            case 2:
                return "订单已退款，收益失效";
        }
        return "";
    }
}
